import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)

export const constantRouterMap = [
  // {
  //   path: '/system', // 父路由路径（根据模块调整）
  //   component: Layout, // el-admin 布局组件，必须引入
  //   redirect: '/system/dataResource',
  //   name: 'System',
  //   meta: { title: '系统管理', icon: 'system' }, // 菜单名称和图标
  //   children: [
  //     {
  //       path: 'dataResource',
  //       name: 'DataResource',
  //       component: () => import('@/views/system/dataResource/index'),
  //       meta: {
  //         title: '数据资源管理',
  //         icon: 'resource',
  //         permissions: ['dataResource:view'] // 关键：与后端权限标识一致
  //       }
  //     }
  //   ]
  // },
  { path: '/login',
    meta: { title: '登录', noCache: true },
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/features/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/features/401'], resolve),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: (resolve) => require(['@/views/features/redirect'], resolve)
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: (resolve) => require(['@/views/home'], resolve),
        name: 'DackgroundManagement',
        meta: { title: '首页', icon: 'index', affix: true, noCache: true }
      }
    ]
  },
  // {
  //   path: '/ResourceDirectory',
  //   component: Layout,
  //   name: 'ResourceDirectory',
  //   meta: { title: '资源编目管理', icon: 'index', affix: false, noCache: true },
  //   children: [
  //     {
  //       path: 'ResourceDirectory',
  //       component: (resolve) => require(['@/views/resourceDirectory/index'], resolve),
  //       name: 'resourceDirectory',
  //       meta: { title: '资源编目管理', icon: 'index' }
  //     }
  //   ]
  // },
  // {
  //   path: '/TaskManagement',
  //   component: Layout,
  //   name: 'TaskManagement',
  //   meta: { title: '任务管理', icon: 'index', affix: false, noCache: true },
  //   children: [
  //     {
  //       path: 'approvalRecords',
  //       component: (resolve) => require(['@/views/TaskManagement/ApprovalRecords/Index'], resolve),
  //       name: 'ApprovalRecords',
  //       meta: { title: '全部任务', icon: 'xxx' }
  //     },
  //     {
  //       path: 'myTask',
  //       component: (resolve) => require(['@/views/TaskManagement/MyTask/Index'], resolve),
  //       name: 'MyTask',
  //       meta: { title: '我的待办', icon: 'xxx' }
  //     },
  //     {
  //       path: 'myApplication',
  //       component: (resolve) => require(['@/views/TaskManagement/MyApplication/Index'], resolve),
  //       name: 'MyApplication',
  //       meta: { title: '我的申请', icon: 'xxx' }
  //     },
  //     {
  //       path: 'myApproval',
  //       component: (resolve) => require(['@/views/TaskManagement/MyApproval/Index'], resolve),
  //       name: 'MyApproval',
  //       meta: { title: '我的审批', icon: 'xxx' }
  //     }
  //   ]
  // },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'center',
        component: (resolve) => require(['@/views/system/user/center'], resolve),
        name: '个人中心',
        meta: { title: '个人中心' }
      }
    ]
  }
  // {
  //   path: '/XinWenZiXun',
  //   component: Layout,
  //   name: 'XinWenZiXun',
  //   meta: { title: '新闻资讯管理', icon: 'index', affix: false, noCache: true },
  //   children: [
  //     {
  //       path: 'XinWenZiXun',
  //       component: (resolve) => require(['@/views/TaskManagement/XinWenZiXun/Index'], resolve),
  //       name: 'XinWenZiXun',
  //       meta: { title: '新闻资讯管理', icon: 'index' }
  //     }
  //   ]
  // },
  // {
  //   path: '/dataResourceMounting',
  //   component: Layout,
  //   name: 'DataResourceMounting',
  //   meta: { title: '数据资源挂载', icon: 'index', affix: false, noCache: true },
  //   children: [
  //     {
  //       path: 'index',
  //       component: (resolve) => require(['@/views/dataResourceMounting/index'], resolve),
  //       name: 'index',
  //       meta: { title: '数据资源挂载', icon: 'index' }
  //     }
  //   ]
  // },
  // {
  //   path: '/processConfiguration',
  //   component: Layout,
  //   name: 'ProcessConfiguration',
  //   meta: { title: '流程配置', icon: 'index', affix: false, noCache: true },
  //   children: [
  //     {
  //       path: 'index',
  //       component: (resolve) => require(['@/views/processConfiguration/index'], resolve),
  //       name: 'index',
  //       meta: { title: '流程配置', icon: 'index' }
  //     }
  //   ]
  // }
]

export default new Router({
  // mode: 'hash',
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
